# Targets:
#
#   build          - Build mod_wtcl.
#   install        - Build and install mod_wtcl.
#   clean          - Remove generated files.
#
# Make variables:
#
#   APACHE_ROOT    - Apache installation directory.
#   TCL_ROOT       - Tcl installation directory.
#   DEBUG          - If set to 1, build a debug version.

default:	_build

WTCL_SRC_DIR=.

!INCLUDE "win.def"

# Config

!if "$(CFG)" == ""
!if "$(DEBUG)" == "1"
CFG=mod_wtcl - Win32 Debug
!else
CFG=mod_wtcl - Win32 Release
!endif
!endif

# Build flags

!IF "$(CFG)" == "mod_wtcl - Win32 Debug"

OUTDIR=.\Debug
INTDIR=.\Debug

CPP_PROJ=/nologo /MDd /W3 /GX /Zi /Od /I "$(APACHE_INCLUDE_DIR)" /I "$(TCL_INCLUDE_DIR)" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /D "WIN32_LEAN_AND_MEAN" /D "WTCL" /D "DEBUG" $(LIBAPREQ_FLAGS) $(TCL_FLAGS) /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_wtcl_src" /FD /c

LINK32_FLAGS=kernel32.lib ws2_32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_wtcl.pdb" /debug /machine:I386 /out:"$(OUTDIR)\mod_wtcl.so" /implib:"$(OUTDIR)\mod_wtcl.lib"

MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32

!ELSE

OUTDIR=.\Release
INTDIR=.\Release

CPP_PROJ=/nologo /MD /W3 /Zi /O2 /Oy- /I "$(APACHE_INCLUDE_DIR)" /I "$(TCL_INCLUDE_DIR)" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "SHARED_MODULE" /D "WIN32_LEAN_AND_MEAN" /D "WTCL"  $(LIBAPREQ_FLAGS) $(TCL_FLAGS) /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\mod_wtcl_src" /FD /c 

LINK32_FLAGS=kernel32.lib ws2_32.lib /nologo /subsystem:windows /dll /incremental:no /pdb:"$(OUTDIR)\mod_wtcl.pdb" /debug /machine:I386 /out:"$(OUTDIR)\mod_wtcl.so" /implib:"$(OUTDIR)\mod_wtcl.lib" /opt:ref 

MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32 

!ENDIF

BSC32_FLAGS=/nologo /o"$(OUTDIR)\mod_wtcl.bsc" 
BSC32_SBRS= \
	

.c{$(INTDIR)}.obj::
   $(CPP) @<<
   $(CPP_PROJ) $< 
<<

.cpp{$(INTDIR)}.obj::
   $(CPP) @<<
   $(CPP_PROJ) $< 
<<

.cxx{$(INTDIR)}.obj::
   $(CPP) @<<
   $(CPP_PROJ) $< 
<<

.c{$(INTDIR)}.sbr::
   $(CPP) @<<
   $(CPP_PROJ) $< 
<<

.cpp{$(INTDIR)}.sbr::
   $(CPP) @<<
   $(CPP_PROJ) $< 
<<

.cxx{$(INTDIR)}.sbr::
   $(CPP) @<<
   $(CPP_PROJ) $< 
<<

LINK32_OBJS= \
	"$(INTDIR)\mod_wtcl.obj" \
	"$(INTDIR)\WtContext.obj" \
  "$(INTDIR)\WtInitCmds.obj" \
	"$(INTDIR)\WtContextEvents.obj" \
	"$(INTDIR)\WtUtil.obj" \
	"$(INTDIR)\WtTable.obj" \
	"$(INTDIR)\WtTableUtil.obj" \
	"$(INTDIR)\WtTableCmds.obj" \
	"$(INTDIR)\WtCollection.obj" \
	"$(INTDIR)\WtCollectionCmds.obj" \
	"$(INTDIR)\WtSettings.obj" \
	"$(INTDIR)\WtExecute.obj" \
	"$(INTDIR)\WtWebErrors.obj" \
	"$(INTDIR)\WtClientRequest.obj" \
	"$(INTDIR)\WtServerCmds.obj" \
	"$(INTDIR)\WtBasicCmds.obj" \
	"$(INTDIR)\WtResponse.obj" \
	"$(INTDIR)\WtCookie.obj" \
	"$(INTDIR)\WtUpload.obj" \
	"$(INTDIR)\WtMultiTable.obj" \
	"$(INTDIR)\WtSession.obj" \
	"$(INTDIR)\WtDbSession.obj" \
	"$(INTDIR)\WtInProcSession.obj" \
	"$(INTDIR)\WtHtmlEntities.obj" \
	"$(INTDIR)\WtMtTable.obj" \
	"$(LIBAPREQ_LIB)" \
	"$(APACHE_LIB)" \
	"$(TCL_LIB)"

"$(OUTDIR)":	
	if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"

"$(OUTDIR)\mod_wtcl.so": "$(OUTDIR)" $(LINK32_OBJS)
    $(LINK32) @<<
  $(LINK32_FLAGS) $(LINK32_OBJS)
<<
    $(MT) /manifest "$(OUTDIR)\mod_wtcl.so.manifest" "/outputresource:$(OUTDIR)\mod_wtcl.so;#2"

!IF "$(NO_EXTERNAL_DEPS)" != "1"
!IF EXISTS("mod_wtcl.dep")
!INCLUDE "mod_wtcl.dep"
!ELSE 
!MESSAGE Warning: cannot find "mod_wtcl.dep"
!ENDIF 
!ENDIF 

SOURCE=mod_wtcl.c
"$(INTDIR)\mod_wtcl.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtContext.c
"$(INTDIR)\WtContext.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtInitCmds.c
"$(INTDIR)\WtInitCmds.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtContextEvents.c
"$(INTDIR)\WtContextEvents.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtUtil.c
"$(INTDIR)\WtUtil.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtTable.c
"$(INTDIR)\WtTable.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtTableUtil.c
"$(INTDIR)\WtTableUtil.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtTableCmds.c
"$(INTDIR)\WtTableCmds.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtCollection.c
"$(INTDIR)\WtCollection.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtCollectionCmds.c
"$(INTDIR)\WtCollectionCmds.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtClientRequest.c
"$(INTDIR)\WtClientRequest.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtServerCmds.c
"$(INTDIR)\WtServerCmds.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtBasicCmds.c
"$(INTDIR)\WtBasicCmds.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtResponse.c
"$(INTDIR)\WtResponse.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtCookie.c
"$(INTDIR)\WtCookie.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtUpload.c
"$(INTDIR)\WtUpload.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtExecute.c
"$(INTDIR)\WtExecute.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtSession.c
"$(INTDIR)\WtSession.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtDbSession.c
"$(INTDIR)\WtDbSession.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtInProcSession.c
"$(INTDIR)\WtInProcSession.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtHtmlEntities.c
"$(INTDIR)\WtHtmlEntities.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

SOURCE=WtMtTable.c
"$(INTDIR)\WtMtTable.obj" : $(SOURCE) "$(INTDIR)"
	$(CPP) $(CPP_PROJ) $(SOURCE)

all:	install

install:	_build _install

mod_wtcl:	_build

$(DICT_LIB):
	cd $(DICT_DIR)
	$(MAKE) DEBUG=$(DEBUG) $(MAKEOPT) /f win.mak
	cd ..

$(LIBAPREQ_LIB):	
	cd $(LIBAPREQ_DIR)
	$(MAKE) DEBUG=$(DEBUG) $(MAKEOPT) /f win.mak
	cd ..

build:	_build

_build:	"$(OUTDIR)\mod_wtcl.so"

_install:	
	-@copy /Y "$(OUTDIR)\mod_wtcl.so" "$(APACHE_MODULE_DIR)"
	-@rem if exist "$(WT_PKG_DIR)" rmdir /S /Q "$(WT_PKG_DIR)"
	-@rem xcopy /Y /E /I wt "$(WT_PKG_DIR)"

clean:	
	-@rmdir /S /Q $(INTDIR)
	-@rmdir /S /Q $(OUTDIR)
	cd $(LIBAPREQ_DIR)
	$(MAKE) DEBUG=$(DEBUG) $(MAKEOPT) /f win.mak clean
	cd ..

